package router

import (
	"express/internal/controller"
	"express/internal/middleware"
	"github.com/gin-gonic/gin"
)

func NewRouter() *gin.Engine {

	userController := controller.NewUserController()
	parcelController := controller.NewParcelController()

	r := gin.New()

	// 跨域配置
	r.Use(middleware.Cors())

	g := r.Group("/express/v1/")
	{
		g.POST("/register", userController.Register)
		g.POST("/login", userController.Login)
		g.POST("/sendParcel", parcelController.SendParcel)

		g.GET("/parcels", parcelController.GetParcelListByReceiver)
		g.GET("/parcels/send", parcelController.GetParcelListBySender)
		g.GET("/identifier", userController.GetIdentifier)

		g.GET("/user", userController.GetUserInfo)
	}

	return r
}
